/*
* (C) Copyright 2013 Philip Kirchhoff 
* 
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
* 
*-------------------------------------------------------------------------------
* This file is part of the DataLogger library by Philip Kirchhoff
* https://code.google.com/p/pk-data-logger/
* SVN: http://pk-data-logger.googlecode.com/svn/trunk
*-------------------------------------------------------------------------------
* Module    : DlDataChannel.h   
* Author    : Kirchhoff, Philip
* Date      : 01.04.2013
*-------------------------------------------------------------------------------
* Header file for DlDataChannel class
*   
*-------------------------------------------------------------------------------
* Change History:
* 01.04.2013  Kirchhoff 	Created
--------------------------------------------------------------------------------
*/


#ifndef DL_DATACHANNEL_H
#define DL_DATACHANNEL_H

#include <string>
#include <vector>
#include <limits>

#define DL_MAX_CHAN_NUM 1000

/***************************************************************************//**
* @brief Base class for DataLogger data channels
 ******************************************************************************/
class DlDataChannel
{
public:

    enum ChannelType{TYPE_DOUBLE, TYPE_FLOAT, TYPE_BOOL, TYPE_LONG, TYPE_ULONG,
                     TYPE_SHORT, TYPE_USHORT, TYPE_STRING};

    DlDataChannel(ChannelType type, unsigned int channelNum,
                  std::string channelId,
                  std::string channelUnit = std::string("-"),
                  std::string channelDescr = std::string("-"));
    ~DlDataChannel();

    /**************************************************************************//**
    * @brief Returns the channel number
    ******************************************************************************/
    unsigned int channelNum(){return mChannelNum;}

    /**************************************************************************//**
    * @brief Returns the channel ID
    ******************************************************************************/
    std::string channelId(){return mChannelId;}

    /**************************************************************************//**
    * @brief Returns the channel unit
    * @return Channel unit
    ******************************************************************************/
    std::string channelUnit(){return mChannelUnit;}

    /**************************************************************************//**
    * @brief Returns the channel type
    * @return Channel type
    ******************************************************************************/
    int channelType(){return mChannelType;}

    /**************************************************************************//**
    * @brief Returns the channel type as string
    * @return Channel type string
    ******************************************************************************/
    std::string channelTypeString();

    /**************************************************************************//**
    * @brief Returns the channel description
    * @return Channel description string
    ******************************************************************************/
    std::string channelDescription(){return mChannelDescr;}

    /**************************************************************************//**
    * @brief Sets the channel unit
    ******************************************************************************/
    void setChannelUnit(std::string unit){mChannelUnit = unit;}

    /**************************************************************************//**
    * @brief Gets the number of stored samples
    * @return Number of stored samples
    ******************************************************************************/
    virtual unsigned int numSamples() = 0;

    /**************************************************************************//**
    * @brief Add a sample to the channel
    ******************************************************************************/
    virtual void addSample(void *pSample) = 0;

    /**************************************************************************//**
    * @brief Get a string-converted sample
    ******************************************************************************/
    virtual std::string sampleString(unsigned int sampleNum) = 0;

    /**************************************************************************//**
    * @brief Clear channel data
    ******************************************************************************/
    virtual void clear() = 0;

protected:

    ChannelType mChannelType;
	std::string mChannelId;
    std::string mChannelUnit;
    std::string mChannelDescr;
    unsigned int mChannelNum;

};


#endif
